<?php
if (get_the_title($post->ID)=='Certificate Classes') {
// Custom Template for Single Posts in Certificate Classes
include 'single-cert-classes.php';
} else {

global $options;
foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$dateformat = get_option('date_format');
$timeformat = get_option('time_format');
$layout = get_post_meta($post->ID, 'template', true);
get_header(); 
?>

<?php 
//set variables for use in template
$cat_ID = get_cat_ID('Collection Highlights');
$cat_link = get_category_link($cat_ID);
?>



  <div id="content">
    <div class="wrap">
    
      <?php wp_reset_query(); 
      if (have_posts()) : while (have_posts()) : the_post(); ?>

      <?php if ($layout != 'full') { ?>
      <div class="column column-narrow">
      
      	<?php 
      	$currCat = get_the_category();
      	$current = $currCat[0]->name;
      	$parent = get_cat_name($currCat[0]->category_parent);
      	
      	//left sidebar heading
    	echo "<p class='heading'>".$parent."</p>";
    	
		//left sidebar menu
		list_cat_posts_all();
		
		?>
      
        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar: Posts (Left)') ) : ?>&nbsp;<?php endif; ?>
      
      </div><!-- end .column-narrow -->
      <?php } ?>
      
      <div class="column <?php if ($layout == 'double') {echo"column-double column-last ";} if ($layout == 'full') {echo"column-full column-last ";} ?>column-content column-double">
	  	<div id="crumbs">
			<!--?php the_breadcrumb(); ?-->
			<?php
				$args = array(
					'prefix' => '<p>',
					'suffix' => '</p>',
					'title' => __( '', 'breadcrumbs-plus' ),
					'home' => __( 'Home', 'breadcrumbs-plus' ),
					'sep' => '»',
					'front_page' => false,
					'bold' => true,
					'show_blog' => false,
					'echo' => true,
					'singular_post_taxonomy' => 'category',
				);
				breadcrumbs_plus( $args );
			?>
		</div>
      	<h1><?php the_title(); ?></h1>

        <?php
       //permanent course information, not conditional
       $collection_info= get_group('Highlight/Theme Details '); // use the Custom Group name
        if (!is_null($collection_info)) {
			echo "<dl class='tablelike'>";
			foreach($collection_info as $coll_info){
			
				//assign each field a variable name
				$usage = $coll_info['theme_detail_usage'][1];
				$status = $coll_info['theme_detail_inhouse_status'][1];
				$formats = get_field_duplicate('theme_detail_format');
				$guides = get_field_duplicate('theme_detail_finding_guide');
				
				//emptyP function removes any '<p>&nbsp;</p>' added (inconsistently) to multiline textbox feilds by magic fields
				if (strlen($usage)>0) { echo "<dt>Usage</dt><dd>".emptyP($usage)."</dd>"; }
				
				if (strlen($status)>0) { echo "<dt>In-House Status</dt><dd>".emptyP($status)."</dd>"; }
				
				if (!is_null ($formats)) {
					echo "<dt>Formats</dt><dd>";
					foreach ($formats as $format) {
						echo emptyP($format);
					}
					echo "</dd>";
				}
				

				if (!is_null ($guides)) {
					echo "<dt>Guides</dt><dd>";
					foreach ($guides as $guide) {
						//extract all URLs from 'a href' string
						echo emptyP($guide);
					}
					echo "</dd>";
				}

					
				/*if (!is_null ($guides)) {
					echo "Guides:";
					foreach ($guides as $guide) {
						//extract URL from 'a href' string
						$url = extract_url($guide);
						if (is_null($url)) {
							echo $guide;
						} else
						if (url_exists($url)) {
							echo $guide;
						}
					}
					echo "<br/>";
				}*/

			//end foreach collection_info as coll_info
			}
			echo "</dl>";
		
		//end if not null collection_info
		}
        ?>
        
        <?php the_tags( '<p class="tags"><strong>Tags:</strong> ', ', ', '</p>'); ?>
        <span class="category"><a href='<?php echo $cat_link; ?>'>Show all themes in Collection Highlights </a></span>
      
      </div><!-- end .column-content -->

      <?php if ($layout != 'double' && $layout != 'full') { ?><div class="column column-narrow column-last">
      
        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar: Posts (Right)') ) : ?>&nbsp;<?php endif; ?>
      
      </div><!-- end .column-narrow -->
      <?php } ?>

<?php endwhile; endif; ?>

      <div class="clear">&nbsp;</div>

    </div><!-- end .wrap -->
  </div><!-- end #content -->

<?php get_footer(); ?>
<?php } ?>